// 定义构造函数
// function Person() {
//   this.name = 'zhichao'
//   this.sex = 'nan'
// }

// Person.prototype.say = function (msg) {
//   console.log('说话：', msg)
// }

// let p1 = new Person()
// p1.say()

class PersonC {

  // 普通属性
  // name
  // sex
  constructor(name, sex) {
    // 初始化已定义好类属性的值
    // 或者一次性初始化属性并且赋值,也可以完成复杂的属性赋值逻辑
    this.name = name
    this.sex = sex

    console.log('构造函数被调用:');

  }

  // 普通方法
  say(msg) {
    console.log(`姓名：${this.name},性别：${this.sex} ,说：${msg}`);
  }
}
class BingRen extends PersonC {
  bingfang
  constructor(bf, ...arg) {
    super(...arg)
    this.bingfang = bf
  }
  sayHi(status) {
    console.log(`在 ${this.bingfang}`);
    this.say(status)
  }
}
let br1 = new BingRen('1号', 'zhichao', 'man')
br1.sayHi('正在康复中。。')
let br2 = new BingRen('抢救室', 'cuimengjiao', 'girl')
br2.sayHi('活蹦乱跳...')
console.log('---------------------------------');
let pc1 = new PersonC('zhichao', 'man')
pc1.say('好好学习')
let pc2 = new PersonC('cuimengjiao', 'girl')
pc2.say('天天向上')

class JiaoShi extends PersonC {
  students
  constructor(stu, ...arg) {
    super(...arg)
    this.students = stu
  }
  sayHi1(status) {
    console.log(`在${this.students}`);
    this.say(status)
  }
}
let stu1 = new JiaoShi('201班', 'zhichao', 'man')
stu1.sayHi1('正在学习')
let stu2 = new JiaoShi('202班', 'cuimengjiao', 'girl')
stu2.sayHi1('正在看书')
